package com.hkts.flow.core.service.flowable.impl;


import com.hkts.flow.api.flowable.ret.VersionVo;
import com.hkts.flow.core.service.flowable.IFlowableIdentityService;
import org.flowable.idm.api.Group;
import org.flowable.idm.api.User;
import org.flowable.idm.engine.impl.persistence.entity.GroupEntityImpl;
import org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl;
import org.flowable.idm.engine.impl.util.CommandContextUtil;
import org.springframework.stereotype.Service;

import java.util.List;

import static org.checkerframework.checker.units.UnitsTools.s;

/**
 * @author : bruce.liu
 * @title: : FlowableIdentityServiceImpl
 * @projectName : flowable
 * @description: 用户组service
 * @date : 2019/11/1411:46
 */
@Service
public class FlowableIdentityServiceImpl extends BaseProcessService implements IFlowableIdentityService {

    @Override
    public void saveUser(User user) {
        System.out.println("identityService:" + user.toString());
//        CommandContextUtil.getUserEntityManager(commandContext).isNewUser(user)
        identityService.saveUser(user);
    }

    @Override
    public void saveGroup(Group group) {
        identityService.saveGroup(group);
    }


    @Override
    public Integer maxVersion() {
        VersionVo versionVo = iflowableIdentityDao.selectMaxVersion();
        if(versionVo==null){
            return 0;
        }
        return versionVo.getMaxVersion();
    }

    @Override
    public void updateUserById(UserEntityImpl user) {
        iflowableIdentityDao.updateUserById(user);
    }

    @Override
    public void updateGrouprById(GroupEntityImpl user) {
        iflowableIdentityDao.updateGroupById(user);
    }

    @Override
    public void deleteMemberShip(UserEntityImpl user) {
        iflowableIdentityDao.deleteMemberShip(user);
    }
}
